<template>
  <div>
    <input type="text" v-model="info" />
    <button @click="cellectionInfo">收集数据</button>
  </div>
</template>

<script>
export default {
  name: "GoSchool",
  data() {
    return {
      info: ""
    };
  },

  components: {},

  computed: {},

  beforeMount() {},

  mounted() {},

  methods: {
    cellectionInfo() {
      // 得到数据
      //   console.log(this.info);
      //处理格式
      const info_test = this.info.trim();
      //检测数据的合法性
      if (!info_test) {
        return;
      }
      //将数据传递给父组件  触发、分发事件  this.$emit参数一 事件名  参数二 传递的数据
      this.$emit("addinfo", info_test);
      //清空输入框
      this.info = "";
    }
  },

  watch: {}
};
</script>
<style lang='' scoped>
</style>